package com.yl.danmo.controller;

import com.yl.common.core.utils.poi.ExcelUtil;
import com.yl.common.core.web.controller.BaseController;
import com.yl.common.core.web.domain.AjaxResult;
import com.yl.common.core.web.page.TableDataInfo;
import com.yl.common.log.annotation.Log;
import com.yl.common.log.enums.BusinessType;
import com.yl.common.security.annotation.RequiresPermissions;
import com.yl.danmo.domain.DanmoInformationCalligrapherPosition;
import com.yl.danmo.service.IDanmoInformationCalligrapherPositionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 书法家职位Controller
 * 
 * @author yl
 * @date 2025-04-18
 */
@RestController
@RequestMapping("/calligrapherPosition")
public class DanmoInformationCalligrapherPositionController extends BaseController
{
    @Autowired
    private IDanmoInformationCalligrapherPositionService danmoInformationCalligrapherPositionService;

    /**
     * 查询书法家职位列表
     */
    @RequiresPermissions("system:calligrapherPosition:list")
    @GetMapping("/list")
    public TableDataInfo list(DanmoInformationCalligrapherPosition danmoInformationCalligrapherPosition)
    {
        startPage();
        List<DanmoInformationCalligrapherPosition> list = danmoInformationCalligrapherPositionService.selectDanmoInformationCalligrapherPositionList(danmoInformationCalligrapherPosition);
        return getDataTable(list);
    }

    /**
     * 导出书法家职位列表
     */
    @RequiresPermissions("system:calligrapherPosition:export")
    @Log(title = "书法家职位", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DanmoInformationCalligrapherPosition danmoInformationCalligrapherPosition)
    {
        List<DanmoInformationCalligrapherPosition> list = danmoInformationCalligrapherPositionService.selectDanmoInformationCalligrapherPositionList(danmoInformationCalligrapherPosition);
        ExcelUtil<DanmoInformationCalligrapherPosition> util = new ExcelUtil<DanmoInformationCalligrapherPosition>(DanmoInformationCalligrapherPosition.class);
        util.exportExcel(response, list, "书法家职位数据");
    }

    /**
     * 获取书法家职位详细信息
     */
//    @RequiresPermissions("system:calligrapherPosition:query")
    @GetMapping(value = "/{calligrapherPositionId}")
    public AjaxResult getInfo(@PathVariable("calligrapherPositionId") Long calligrapherPositionId)
    {
        return success(danmoInformationCalligrapherPositionService.selectDanmoInformationCalligrapherPositionByCalligrapherPositionId(calligrapherPositionId));
    }

    /**
     * 新增书法家职位
     */
    @RequiresPermissions("system:calligrapherPosition:add")
    @Log(title = "书法家职位", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DanmoInformationCalligrapherPosition danmoInformationCalligrapherPosition)
    {
        return toAjax(danmoInformationCalligrapherPositionService.insertDanmoInformationCalligrapherPosition(danmoInformationCalligrapherPosition));
    }

    /**
     * 修改书法家职位
     */
    @RequiresPermissions("system:calligrapherPosition:edit")
    @Log(title = "书法家职位", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DanmoInformationCalligrapherPosition danmoInformationCalligrapherPosition)
    {
        return toAjax(danmoInformationCalligrapherPositionService.updateDanmoInformationCalligrapherPosition(danmoInformationCalligrapherPosition));
    }

    /**
     * 删除书法家职位
     */
    @RequiresPermissions("system:calligrapherPosition:remove")
    @Log(title = "书法家职位", businessType = BusinessType.DELETE)
	@DeleteMapping("/{calligrapherPositionIds}")
    public AjaxResult remove(@PathVariable Long[] calligrapherPositionIds)
    {
        return toAjax(danmoInformationCalligrapherPositionService.deleteDanmoInformationCalligrapherPositionByCalligrapherPositionIds(calligrapherPositionIds));
    }
}
